%p
  = _("Title")
  = ":"
  = text_field 'media', 'title',:size=>50
%p
  = _("Text")
  = "<br/>"
  = textile_editor('media', 'text',:cols=>80,:rows=>20)
#preview  
= link_to_remote "Preview", :url => { :action => "preview", :controller => "media" },:update => "preview",:with => "'text=' + encodeURIComponent($('media_text').value)+'&title='+encodeURIComponent($('media_title').value)",:loading => "Element.show('busy_media')",:complete => "Element.hide('busy_media')" 
= "<br>"
%p
  = _("Category")
  %select{:id=>"media_category_id", :name=>"media[category_id]"}
    - @categories.each do |thecategory|
      - if thecategory.id==1
        %option{:value=>thecategory.id, :selected=>true}
          = thecategory.name
      - else
        %option{:value=>thecategory.id}
          = thecategory.name
%p
  = _("Tags")
  = ":"
  #tags_field
    = text_area('form', 'tags',:cols=>100,:rows=>5)+"<br />"
  = _("Existing tags")+":<br />"
  = Tag.find(:all,:order=>"name ASC").collect {|t| link_to_remote(t.name,:update=>"tags_field",:loading => "Element.show('busy_media')",:complete => "Element.hide('busy_media')" ,:url=>{:action=>"update_tags"},:with=>"'tag=#{t.name}'+'&list='+encodeURIComponent($('form_tags').value)")}.join(" ")+"<br />"
%p
  = _("Published")
  = ":"
  = check_box 'media', 'published',:checked=>true,:onclick=>"Element.toggle('publicationdate')"
  %p{:id=>"publicationdate",:style=>'display:block;'}
    = _("Publication date")
    = ":"
    = calendar_date_select_tag "media_publicationdate", Time.now, :time => true,:name=>"media[publicationdate]"
%p
  = _("Expires")
  = ":"
  = check_box 'media', 'expires',:onclick=>"Element.toggle('expirationdate')"
  %p{:id=>"expirationdate", :style=>'display:none;'}
    = _("Expiration date")
    = ":"
    = calendar_date_select_tag "media_expirationdate", Time.now, :time => true,:name=>"media[expirationdate]"
= submit_tag _('Create')
= textile_editor_initialize
= "<br />"
= link_to (_('Back'), :action => 'listadmin' )
= "<br />"
